import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'

//配置请求根路径
axios.defaults.baseURL = import.meta.env.VITE_APP_BASE_URL
//axios拦截器拦截每一个请求,有token就配置头信息的token
axios.interceptors.request.use(config => {
  const token = localStorage.getItem('authorization')
  if (token) {  // 判断是否存在token，如果存在的话，则每个http header都加上token
    config.headers.authorization = token
  }
  return config
}, error => Promise.reject(error))

//解决路径跳转的报错
//import Router from 'vue-router'
//
//const originalPush = Router.prototype.push
//Router.prototype.push = function push(location) {
//  return originalPush.call(this, location).catch(err => err)
//}

export const app = createApp(App).use(router).mount('#app')
